<%- partial('../editor_sidebar') %>

<div id='content'>
  <div class='panel'>
    <div class='header'>
      <ol class='breadcrumb'>
        <li><a href='/'>主页</a><span class='divider'>/</span></li>
        <li class='active'>创建课程</li>
      </ol>
    </div>
    <div class='inner post'>
      <% if(typeof(edit_error) !== 'undefined' && edit_error){ %>
      <div class="alert alert-error">
        <a class="close" data-dismiss="alert" href="#">&times;</a>
        <strong><%= edit_error %></strong>
      </div>
      <% } %>
      <% if(typeof(error) !== 'undefined' && error){ %>
      <div class="alert alert-error">
        <strong><%= error %></strong>
      </div>
      <% }else{ %>
      <% if (typeof(action) !== 'undefined' && action === 'edit') { %>
      <form id='create_topic_form' action='/topic/<%= topic_id %>/edit' method='post'>
        <% } else { %>
        <form id='create_course_form' action='/course/create' method='post'>
          <% } %>
          <fieldset>
             <span class="tab-selector">课程名称:</span>
             <input type="text" class="form-control" id="course-name" name = "courseName" placeholder="请输入课程名称">
             <span class="tab-selector">老师名称:</span>
             <input type="text" class="form-control" id="teacher-name" name = "teacherName" placeholder="请输入课程老师名称">
                <div class='editor_buttons'>
                  <input type="submit" class='span-primary submit_btn' data-loading-text="提交中"
                         value="提交">
                </div>
              </div>
            </div>
          </fieldset>
        </form>
    </div>
    <% } %>
  </div>
</div>

<script>
  (function () {//检测是否填写完全信息
    $('#create_course_form').on('submit', function (e) {
      var courseNameValue = $('#course-name').val();
      var teacherNameValue = $('#teacher-name').val();
      if (!courseNameValue || !teacherNameValue) {
        alert('请填写完全信息');
        $('.submit_btn').button('reset');
        $('.tab-selector').css('color', 'red');
        return false;
      }
    });
  })();
</script>
